package ishitong.vehicleManagement.service.biz.impl;

import ishitong.vehicleManagement.dao.ImportantVehicleDao;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.ishitong.platform.common.page.Page;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.ArrayList;
import ishitong.vehicleManagement.model.ImportantVehicle;
import ishitong.vehicleManagement.model.ImportantVehicleQuery;
import ishitong.vehicleManagement.service.biz.ImportantVehicleService;

/** @pdOid a9d602be-47f4-4666-a33e-aed60f20a6f8
 * @创建日期:2013-10-11 15:26:06
 * 
 * @功能描述:ImportantVehicle业务服务
 * @开发人员:福建视通 */
@Service(value="importantVehicleService")
@Transactional
public class ImportantVehicleServiceImpl implements ImportantVehicleService {
   /** @pdOid 883cf665-043b-435b-8624-78d040becd83
       @pdRoleInfo migr=yes name=ImportantVehicleDao assc=association6 */
   @Autowired
   private ImportantVehicleDao importantVehicleDao;
   /** @pdOid 37ada455-9e15-4f76-b6ea-62a9577f1bb8
       @pdRoleInfo migr=yes name=SPIVehicleService assc=association8 */
   @Autowired
   private SPIVehicleService spiVehicleService;
   /** @pdOid 57f47c13-9fbe-4918-94b8-ef5c9cc9d6c4
       @pdRoleInfo migr=yes name=SPISysCodeService assc=association11 */
   @Autowired
   private SPISysCodeService spiSysCodeService;
   
   /** @param iv
    * @pdOid 6b1c0232-704f-43b6-9b95-f503d9fff3cd */
   private void setImportantVehicleProperty(ImportantVehicle iv) {
   	   iv.setPlateType(spiSysCodeService.getSysCodeById(iv.getPlateTypeId()));
   	   iv.setVehicleColor(spiSysCodeService.getSysCodeById(iv.getVehicleColorId()));
   //	   iv.setVehicleType(spiSysCodeService.getSysCodeById(iv.getVehicleTypeId()));
      }
   
   /** @param id
    * @pdOid 6e00228d-e889-4e67-9e1b-c0e1c4eaa21e
    * @功能描述: 删除ImportantVehicle
    * @异常类型: */
   public void delete(String id) {
   	if(id!=null&&!id.trim().equals("")){
   		String[] idList=id.split(";");
   		for(int i=0;i<idList.length;i++){
   			if(idList[i]!=null&&!idList[i].trim().equals("")){
   				this.importantVehicleDao.remove(idList[i]);
   			}
   		}
   	}
   }
   
   /** @param importantVehicle
    * @pdOid 27b3e342-f8df-46d2-9de3-400ca77a32e2
    * @功能描述: 删除ImportantVehicle
    * @异常类型: */
   public void deleteByModel(ImportantVehicle importantVehicle) {
   	this.importantVehicleDao.remove(importantVehicle);
   }
   
   /** @param id
    * @pdOid a77eaa72-92ef-45db-9aa5-282cc7e709b0
    * @功能描述: 查询ImportantVehicle
    * @异常类型: */
   public ImportantVehicle findById(String id) {
    ImportantVehicle importantVehicle = this.importantVehicleDao.findByPrimaryKey(id);
    setImportantVehicleProperty(importantVehicle);    
    return importantVehicle;
   }
   
   /** @param importantVehicle
    * @pdOid 2e38a6fb-d4aa-47bf-9259-395584959859
    * @功能描述: 新增与修改ImportantVehicle
    * @异常类型: */
   public void save(ImportantVehicle importantVehicle) {
   	this.importantVehicleDao.save(importantVehicle);
   }
   
   /** @param query 
    * @param pageSize 
    * @param pageNum
    * @pdOid ebc24136-17f8-407a-9681-bef85b53c2c9
    * @功能描述: 通过ImportantVehicleQuery对象，查询ImportantVehicle
    * @异常类型: */
   public Page findPage(ImportantVehicleQuery query, int pageSize, int pageNum) {
   Page<ImportantVehicle> page = this.importantVehicleDao.findPage(query,pageSize,pageNum);
      List<ImportantVehicle> lst = page.getResults();
      for (ImportantVehicle iv: lst) {
      	setImportantVehicleProperty(iv);
      }
      return page;
     }
   
   /** @param query
    * @pdOid cf2bf08f-0006-48e2-95ec-bc3429295aa0
    * @功能描述: 通过ImportantVehicleQuery对象，查询ImportantVehicle
    * @异常类型: */
   public List<ImportantVehicle> findList(ImportantVehicleQuery query) {
   	return this.importantVehicleDao.findList(query);
   }

}